<div id="comment_editor">
	<h3>编辑器</h3>
	<form method="post" action="<?php echo $this->get_info('path') ?>index.php?m=ajax&p=addcomment" id="ajax_form">
		<input type="hidden" name="aid" id="aid" value="<?php if( $this->get_article_content( 'id' ) != '' ){ echo $this->get_article_content( 'id' ); }else{ echo '0';} ?>" />
		<div id="editor_tips"></div>
		<div id="guest_info">
			<input name="username" id="username" type="text" maxlength="16" value="" class="input" />&nbsp;&nbsp;昵称<br /><br />
			<input name="email" id="email" type="text" maxlength="100" value="" class="input" />&nbsp;&nbsp;邮箱<br /><br />
			<input name="index" id="index" type="text" maxlength="100" value="" class="input" />&nbsp;&nbsp;主页<br /><br />
		</div>
		<div id="user_info"></div>
		<textarea name="comment" id="commentText" rows="8" cols="50" tabindex="4"></textarea><br /><br />
		<input type="submit" value="立即发表" id="comment_submit" /> <input type="checkbox" class="checkbox" name="hide" id="hide" /> 悄悄话&nbsp;<input type="checkbox" class="checkbox" name="remember" id="remember" /> 记住我<br />
	</form>
</div>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
	$('#ajax_form').ajaxForm({ beforeSubmit: function(){
		$("#comment_submit").attr('disabled',true);
		$('#editor_tips').html('正在提交……');
	}, success: function(data){
		 var StrHtml = data.split("|$|")[0];
		 var Bool = data.split("|$|")[1];
		 if ( Bool == "True" ){
	 	 	 $("#editor_tips").html("");
	 	 	 $("#commentText").val("");
	 	 	 $("#ajax_comment").html( StrHtml + $("#ajax_comment").html() );
	 	 	 window.location.hash = '#ajax_comment';
		 }else{
			 $("#editor_tips").html("<font color=red>" + StrHtml + "</font>");
		 }
		 $("#comment_submit").attr('disabled',false);
	}});
});
// @ 回复
function comment_reply( cid ) {
	$("#commentText").val( "{@" + cid + "}\n" + $("#commentText").val() );
	setTimeout( '$("#commentText")[0].focus();', 50 );
}
// 加载用户信息
function get_guestinfo() {
	if( get_cookie('<?php echo APP_PREFIX ?>username') != '' ) {
		$("#username").val( get_cookie('<?php echo APP_PREFIX ?>username') );
		$("#email").val( get_cookie('<?php echo APP_PREFIX ?>email') );
		$("#index").val( get_cookie('<?php echo APP_PREFIX ?>index') );
		$("#guest_info").css('display','none');
		$("#user_info").html( "欢迎回来, <b>" + get_cookie('<?php echo APP_PREFIX ?>username') + "</b> [<a href=\"#\" onclick=\"$('#guest_info').css('display','block');$('#user_info').css('display','none');return false;\">更换帐号</a>]<br><br>" );
	}
	if ( get_cookie('<?php echo APP_PREFIX ?>remember') == 1 ) {
		$("#remember").attr('checked',true);
	}
}
// 获取COOKIE
function get_cookie( name ) {
	 if (document.cookie.length > 0) {
		 var start = name + '=';
		 var offset = document.cookie.indexOf(start);
		 if (offset != -1) {
			offset += start.length;
			var end = document.cookie.indexOf(';',offset);
			if (end == -1) {
				end = document.cookie.length;
			}
			return decodeURIComponent(document.cookie.substring(offset, end));
		 }
	 }
	 return '';
}
</script>
